package com.sunxu.springboot.demo.enumeration;

/**
 * @Author: 孙许
 * @Date: 2018-08-13
 * @Time: 1:49
 * @Description:
 */

public enum SexEnum {
    /**
     * 数据库中1代表男性，2代表女性
     */
    MALE(1, "男"),
    FEMALE(2, "女");

    private int id;
    /**
     * 具体的属性
     */
    private String name;

    SexEnum(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public static SexEnum getEnumById(int id) {
        for (SexEnum sex : SexEnum.values()) {
            if (sex.getId() == id) {
                return sex;
            }
        }
        return null;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
